package expansion.sort;
/*
插入排序
思路：
 */

import java.util.Arrays;

public class InsertSort {
    public static void main(String[] args) {
        int[] arr = {7,3,6,9,2,5,4,0,8};
        for (int i = 1; i < arr.length; i++) {
            int temp = arr[i];
            int j;
            for (j=i-1; j >= 0 ; j--) {
                if (arr[j]>temp){
                    arr[j+1] = arr[j];
                }else{
                    break;
                }
            }
            arr[j+1]=temp;
        }
        System.out.println(Arrays.toString(arr));
    }
}
